<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>25_案例练习-0去掉数组中元素的值是0的,重新生成一个新数组</title>
    </head>
    <body>
        <script>
            // 去掉数组中元素的值是0的,重新生成一个新数组
            var arr = [1,0,0,2,3,0,0,4,5,0,0,6];

            var new_arr = [];

            for(var i = 0; i < arr.length; i++){
                if(arr[i] != 0) {
                    new_arr[new_arr.length] = arr[i];
                }
            }

            console.log(new_arr);



        </script>
    </body>
</html>